<ui:composition xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.prime.com.tr/ui"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:tcc="http://www.faesppr.br/componentes"
	template="../template.xhtml">

	<ui:define name="conteudo">
	
		<f:metadata>
			<f:event type="preRenderView" listener="#{sessaoMBean.verificaSessao}"></f:event>
		</f:metadata>
	
	
	    <div style="margin: auto; width: 985px; padding-top: 20px;">	
	    
	    <h:form id="formListaProfissionais">
            <p:panel style="width:985px" id="painelTabela">     
            	   <p:ajaxStatus style = "width:26px;height:26px" >
		    		<f:facet name="start">
		    		    <h:graphicImage library="img/icons" name="connect_active.gif" />
					</f:facet>
					<f:facet name="complete">
						<h:graphicImage library="img/icons" name="connect_idle.gif" />
					</f:facet>
		
				</p:ajaxStatus>	
               <p:dataTable 
               		var="var"
               		id="tabelaProfissionais"
                 	widgetVar="tabelaProfissionais"
                 	value="#{profissionalMBean.lazyModel}" 
                	paginator="true"
                	rows="10"
                	lazy="true"
                	emptyMessage="Não há registros."
                	paginatorTemplate="{RowsPerPageDropdown}{FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
                 	paginatorPosition="bottom"
                 	rowsPerPageTemplate="10,20,30" 
                 	onRowSelectComplete="carDialog.show()" 
                 	onRowSelectUpdate="display" 
                 	dynamic="false" 
                 	
                 	
                >

				<f:facet name="header">Profissionais Cadastrados</f:facet>
			    	<p:column>
			    	
	                	<p:column style="width:16px">
                        	<p:rowToggler />
                        </p:column>	        			       
					</p:column>
					
				    <p:column  
				    	filterBy="#{var.nome}"
				    	filterStyle="width:130px; " 
				    >
				    	<f:facet name="header">
				    		Nome
				    	</f:facet>
						<h:outputText value="#{var.nome}" />
				    </p:column>
				    
					<p:column 
				    	filterBy="#{var.login}"
				    	style="width:100px"
				    	filterStyle="width:85px;"
				    >
						<f:facet name="header">
							Login
						</f:facet>
						<h:outputText value="#{var.login}" />
					</p:column>
					
					<p:column 
				    	filterBy="#{var.funcao}"
				    	style="width:130px"
				    	filterStyle="width:115px;"
				    >
						<f:facet name="header">
							Função
						</f:facet>
						<h:outputText value="#{var.funcao}" />
					</p:column>		
								
							<p:column 
							      filterBy="#{var.rg}" style="width:85px" filterStyle="width:70px">
								<f:facet name="header">RG</f:facet>
								<h:outputText value="#{var.rg}" />
							</p:column>	
							<p:column 
							      filterBy="#{var.cpf}" style="width:85px" filterStyle="width:70px">
								<f:facet name="header">CPF</f:facet>
								<h:outputText value="#{var.cpf}" />
							</p:column>																										
							<p:column 
							      filterBy="#{var.unidade.nome}" style="width:85px" filterStyle="width:70px">
								<f:facet name="header">Unidade</f:facet>
								<h:outputText value="#{var.unidade.nome}" />
							</p:column>	
							<p:column 
							      filterBy="#{var.status}" style="width:55px" filterStyle="width:50px">
								<f:facet name="header">Status</f:facet>
								<h:outputText value="#{var.status}" />
							</p:column>								
									
							<p:column style="width:16px">
							<p:commandButton
							    action="#{profissionalMBean.flagSelecionado}"
							    update = "profissionalAlteracao:gridProfissional"
							    oncomplete="alteracao.show()" title="Alterar dados do Usuário" image="ui-icon-pencil">
							    <f:param name="parametro" value="#{var.id}" />    
							</p:commandButton>
							</p:column>
							
												
							<p:column style="width:16px">
							<p:commandButton
							    action="#{profissionalMBean.flagSelecionado}"
							    update="alteraSenhaGrid"
							    oncomplete="alteraSenha.show()" title="Resetar senha do Usuário para numero do RG" image="ui-icon-key">
							    <f:param name="parametro" value="#{var.id}" />    
							</p:commandButton>						
							</p:column>			
													
							
												
            				<p:rowExpansion>
            						<p:panel header="Dados Complementares" style="width:350px">
            								<h:panelGrid id="display" columns="2" cellpadding="4" style="width:300px;" styleClass="ui-widget-content">

              										  <h:outputText value="Telefone Residencial:" /><h:outputText value="#{var.telefoneRes}"/>
              										  <h:outputText value="Celular:" /><h:outputText value="#{var.celular}"/>
               										  <h:outputText value="Telefone Comercial:" /><h:outputText value="#{var.telefoneCom}"/>
                									  <h:outputText value="Ramal:" /><h:outputText value="#{var.ramal}"/>
                									  <h:outputText value="email:" /><h:outputText value="#{var.email}"/>

            								</h:panelGrid>
           							 </p:panel>    

        					</p:rowExpansion>
				</p:dataTable>     
     		</p:panel>
<div style="text-align:center">
<h:panelGrid columns="2">
	<p:panel header="Export Todos os registros">
		<h:commandLink>
		    <h:graphicImage library="img/export" name="excel.png" style="border:none"/>
			<p:dataExporter type="xls" target="tabelaProfissionais" fileName="profissionais" excludeColumns="0,8,9,10"/>
		</h:commandLink>

		<h:commandLink>
		    <h:graphicImage library="img/export" name="pdf.png" style="border:none"/>
			<p:dataExporter type="pdf" target="tabelaProfissionais" fileName="profissionais" excludeColumns="0,8,9,10"/>
		</h:commandLink>
		
		<h:commandLink>
		<h:graphicImage library="img/export" name="csv.png" style="border:none"/>
			<p:dataExporter type="csv" target="tabelaProfissionais" fileName="profissionais" excludeColumns="0,8,9,10"/>
		</h:commandLink>
		
		<h:commandLink>
		    <h:graphicImage library="img/export" name="xml.png"  style="border:none"/>
			<p:dataExporter type="xml" target="tabelaProfissionais" fileName="profissionais" excludeColumns="0,8,9,10" />
		</h:commandLink>
	</p:panel>
	
	<p:panel header="Exportar Página">
		<h:commandLink>
		  	<h:graphicImage library="img/export" name="excel.png"  style="border:none"/>
			<p:dataExporter type="xls" target="tabelaProfissionais" fileName="profissionais" excludeColumns="0,8,9,10" pageOnly="true"/>
		</h:commandLink>

		<h:commandLink>
			<h:graphicImage library="img/export" name="pdf.png"  style="border:none"/>
			<p:dataExporter type="pdf" target="tabelaProfissionais" fileName="profissionais" excludeColumns="0,8,9,10" pageOnly="true"/>
		</h:commandLink>
		
		<h:commandLink>
			<h:graphicImage library="img/export" name="csv.png"  style="border:none"/>
			<p:dataExporter type="csv" target="tabelaProfissionais" fileName="profissionais" excludeColumns="0,8,9,10" pageOnly="true"/>
		</h:commandLink>
		
		<h:commandLink>
			<h:graphicImage library="img/export" name="xml.png"  style="border:none"/>
			<p:dataExporter type="xml" target="tabelaProfissionais" fileName="profissionais" excludeColumns="0,8,9,10" pageOnly="true"/>
		</h:commandLink>
	</p:panel>
</h:panelGrid>
</div>
		</h:form>
	  </div>
	  <h:form id="profissionalAlteracao">
	  
	     <p:dialog header="Alteração de Profissional"  widgetVar="alteracao" width="480" modal="true" resizable="false" closeListener="#{profissionalMBean.limparCampos}">
	           <p:panel id="gridProfissional" style="border:none">
	            	<tcc:profcadastro	
				   		renderedAlterar="true"
						renderedSalvar="false"
						renderedLimpar = "false"
						renderedFechar = "true"
						update="formListaProfissionais:tabelaProfissionais profissionalAlteracao:gridProfissional messageGrowl:growl" 		
					/>
				</p:panel>
        </p:dialog>	
	  
	  </h:form>
	  
	<h:form id="formAlteraSenha">
	<h:panelGrid id ="alteraSenhaGrid">
         <p:confirmDialog
         	message="Tem certeza que deseja resetar a senha do profissional #{profissionalMBean.profissional.nome}?"
			modal="true"
			header="Confirmação de alteração de senha"
			severity="alert"
			widgetVar="alteraSenha"
		 >
			<p:commandButton 
		 		value="Sim"
		 		update="messageGrowl:growl" 
		        oncomplete="alteraSenha.hide()"
			    action="#{profissionalMBean.resetarSenha}"
		    />
		    
			<p:commandButton
				value="Não"
				onclick="alteraSenha.hide()"
				type="button"
			/> 
				
		</p:confirmDialog>
	</h:panelGrid>
	</h:form>
	  
	</ui:define>
	



</ui:composition>
